#!ipxe

goto ${menu} ||

:live_menu
set os Mint Live
menu ${os} - Current Arch [ ${arch} ]
iseq ${arch} x86_64 && set arch_a amd64 || set arch_a ${arch}
item --gap ${os} Versions
item 20 ${space} ${os} 20
item 19 ${space} ${os} 19
item lmde ${space} ${os} LMDE
choose live_version || goto live_exit
menu ${os} ${live_version}
item --gap ${os} Flavors
goto ${live_version}

:20
{% for key, value in endpoints.items() | sort %}
{% if value.os == "mint" and 'squash' in key and value.version == "20" %}
item {{ key }} ${space} {{ value.os | title }} {{ value.version }} {{ value.flavor | title}}
{% endif %}
{% endfor %}
goto flavor_select

:19
{% for key, value in endpoints.items() | sort %}
{% if value.os == "mint" and 'squash' in key and value.version == "19" %}
item {{ key }} ${space} {{ value.os | title }} {{ value.version }} {{ value.flavor | title}}
{% endif %}
{% endfor %}
goto flavor_select

:lmde
{% for key, value in endpoints.items() | sort %}
{% if value.os == "mint" and value.version == "lmde" %}
item {{ key }} ${space} {{ value.os | title }} {{ value.version }} {{ value.flavor | title}}
{% endif %}
{% endfor %}
goto flavor_select

:flavor_select
choose flavor || goto live_menu
echo ${cls}
goto ${flavor} ||

{% for key, value in endpoints.items() | sort %}
{% if value.os == "mint" and 'squash' in key %}
{% set kernel_name = value.kernel %}
:{{ key }}
set squash_url ${live_endpoint}{{ value.path }}filesystem.squashfs
{% for key, value in endpoints.items() | sort %}
{% if key == kernel_name %}
set kernel_url ${live_endpoint}{{ value.path }}
{% endif %}
{% endfor %}
goto {{ value.version }}-boot
{% endif %}
{% endfor %}

:20-boot
imgfree
kernel ${kernel_url}vmlinuz ip=dhcp boot=casper netboot=url url=${squash_url} initrd=initrd ${cmdline}
initrd ${kernel_url}initrd
boot

:19-boot
imgfree
kernel ${kernel_url}vmlinuz ip=dhcp boot=casper netboot=http fetch=${squash_url} initrd=initrd ${cmdline}
initrd ${kernel_url}initrd
boot

:lmde-boot
imgfree
kernel ${kernel_url}vmlinuz boot=live fetch=${squash_url} initrd=initrd ${cmdline} 
initrd ${kernel_url}initrd
boot

:live_exit
clear menu
exit 0

